package com.xiangban.yanglaodajie_admin.controller;

import com.xiangban.yanglaodajie_admin.entity.res.ApiResult;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
 * @Author Mr. MaYaYun
 * @Data 2021/6/10 11:56
 */
@RestController
@RequestMapping("/test")
public class TestController {

    @PostMapping("/login")
    public ApiResult<Object> login(@RequestBody Map<String,Object> map){
        map.put("token","admin-token");

        return ApiResult.newSuccess(map);
    }
    @GetMapping("/userInfo")
    public ApiResult<Object> userInfo(HttpServletRequest request){
        String token = request.getParameter("token");
        System.out.println(token);
        ArrayList<String> strings = new ArrayList<>();
        strings.add("merchant");
//        strings.add("merchant-schedule");
        HashMap<String, Object> map = new HashMap<>();
        map.put("avatar","https://wpimg.wallstcn.com/f778738c-e4f8-4870-b634-56703b4acafe.gif");
        map.put("introduction","我是超级管理员");
        map.put("name","Super Admin");
        map.put("roles",strings);
        return ApiResult.newSuccess(map);
    }
    @RequestMapping("/logout")
    public ApiResult<Object> logout(){
        return ApiResult.newSuccess();
    }
}
